package com.acwing.partition9;

import java.io.*;
import java.util.ArrayList;
import java.util.LinkedList;
import java.util.List;

/**
 * @author `RKC`
 * @date 2021/11/29 17:57
 */
public class AC848有向图的拓扑序列 {

    public static void main(String[] args) throws IOException {
        BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
        BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(System.out));
        String[] s = reader.readLine().split(" ");
        int n = Integer.parseInt(s[0]), m = Integer.parseInt(s[1]);
        int[][] edges = new int[m][2];
        for (int i = 0; i < m; i++) {
            s = reader.readLine().split(" ");
            int x = Integer.parseInt(s[0]), y = Integer.parseInt(s[1]);
            edges[i][0] = x;
            edges[i][1] = y;
        }
        List<Integer> answer = topological(n, edges);
        if (answer.size() != n) {
            writer.write("-1\n");
        } else {
            for (int i = 0; i < answer.size(); i++) writer.write(answer.get(i) + " ");
        }
        writer.flush();
    }

    private static List<Integer> topological(int n, int[][] edges) {
        int m = edges.length, index = 0;
        List<Integer> answer = new ArrayList<>();
        int[] head = new int[n + 1], element = new int[m], next = new int[m], inDegree = new int[n + 1];
        for (int i = 1; i <= n; i++) head[i] = -1;
        for (int[] edge : edges) {
            element[index] = edge[1];
            next[index] = head[edge[0]];
            head[edge[0]] = index++;
            inDegree[edge[1]]++;
        }
        //将所有入度为0的结点加入到队列中
        LinkedList<Integer> queue = new LinkedList<>();
        for (int i = 1; i <= n; i++) {
            if (inDegree[i] == 0) queue.addLast(i);
        }
        while (!queue.isEmpty()) {
            int u = queue.pollFirst();
            answer.add(u);
            //遍历其邻结点
            for (int i = head[u]; i != -1; i = next[i]) {
                int v = element[i];
                inDegree[v]--;
                if (inDegree[v] == 0) queue.addLast(v);
            }
        }
        return answer;
    }
}
